#include<bits/stdc++.h>
using namespace std;
#define int long long
#define debug cout<<-1<<endl
const int maxn=1e5+5;
int num[maxn];
int ans,tp;
int sum[maxn];
int a[maxn];
int n;
signed main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    scanf("%lld",&n);
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
    }
    sort(a+1,a+n+1);
    num[1]=1;int tot=1;
    for(int i=2;i<=n;i++){
        if(a[i]!=a[i-1]){
            num[++tot]=1;
        }
        else{
            num[tot]++;
        }
    }
    /*
    for(int i=1;i<=tot;i++){
        cout<<num[i]<<" ";
    }
    cout<<endl;
    */
    for(int i=1;i<=tot;i++){
        sum[i]=sum[i-1]+num[i];
    }
    int tp=1;
    int stp=num[1];
    int la=0;
    while(tp<=tot){
        int id=lower_bound(sum+tp+1,sum+tot+1,2*stp+sum[la])-sum;
        //cout<<id<<endl;
        if(id>=tot+1){
            //cout<<" "<<sum[tot]<<" "<<sum[tp]<<endl;
            ans+=sum[tot]-sum[tp];
            break;
        }
        else{
            //cout<<" "<<stp<<endl;
            ans+=stp;
            stp=sum[id]-sum[tp];
            la=tp;
            tp=id;
            if(tp==tot){
                break;
            }
        }

    }
    /*
    7
    1 1 1 1 2 2 3

    3
    */
    cout<<n-ans<<endl;
}
